package com.mrd.gtimp.business.entity;

import com.mrd.gtimp.base.entity.Company;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

/**
 * <p>
 * application name: gtimp
 * <p>
 * copyright: Copyright@2012 明睿达科技有限公司
 */

/**
 * 供应商报价
 * @author yangyl
 */
@Entity(name = "T_BIZ_DECLARATION_OFFER")
public class DeclarationOffer implements Serializable {
	private static final long	serialVersionUID	= 1L;

	/**
	 * id
	 */
	@Id
	@GeneratedValue(generator = "paymentableGenerator")
	@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
	@Column(name = "ID")
	private String				id;

	/**
	 * 出口报关金额
	 */
	@Column(name = "declaration_amount")
	private double				declaration_amount;

	/**
	 * 进口报关金额
	 */
	@Column(name = "imp_declaration_amount")
	private Double				imp_declaration_amount;

	/**
	 * 免报关费柜数
	 */
	@Column(name = "container_amount")
	private Integer				container_amount;

	/**
	 * 进口免报关费柜数
	 */
	@Column(name = "imp_container_amount")
	private Integer				imp_container_amount;

	/**
	 * 价格开始时间
	 */
	@Column(name = "price_begin_time")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date				price_begin_time;

	/**
	 * 价格结束时间
	 */
	@Column(name = "price_end_time")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date				price_end_time;

	/**
	 * 创建时间
	 */
	@Column(name = "REG_DATE", updatable = false)
	private Date				regDate;

	/**
	 * 创建人
	 */
	@Column(name = "REG_USER", updatable = false)
	private String				reg_user;

	/**
	 * 修改时间
	 */
	@Column(name = "modi_date")
	private Date				modi_date;

	/**
	 * 修改人
	 */
	@Column(name = "modi_user")
	private String				modi_user;

	/**
	 * 状态
	 */
	@Column(name = "state")
	private String				state;

	/**
	 * 审核时间
	 */
	@Column(name = "review_date")
	private Date				review_date;

	/**
	 * 审核人
	 */
	@Column(name = "review_user")
	private String				review_user;

	/**
	 * 提交时间
	 * @return
	 */
	@Column(name = "confirm_time")
	private Date				confirmTime;

	/**
	 * 提交人
	 */
	@Column(name = "confirm_user")
	private String				confirm_user;

	/**
	 * 所属公司
	 * @return
	 */
	@ManyToOne
	@JoinColumn(updatable = false, name = "COM_ID")
	private Company				owner;

	/**
	 * 上传文件
	 * @return
	 */
	@OneToOne
	@JoinTable(name = "T_BIZ_ATTACHMENT", joinColumns = @JoinColumn(name = "BILL_NO"),
	        inverseJoinColumns = @JoinColumn(name = "ID"))
	private Attachment			upload_id;

	/**
	 * 审核理由
	 * @return
	 */
	@Column(name = "review_reason")
	private String				review_reason;

	/**
	 * 报关公司
	 * @return
	 */
	@Column(name = "declaration_company")
	private String				declaration_company;

	/**
	 * 报关公司id
	 * @return
	 */
	@Column(name = "declaration_company_id")
	private String				declaration_company_id;

	/**
	 * 报价公司所属港口
	 * @return
	 */
	@Column(name = "port")
	private String				port;

	/**
	 * 报价公司所属港口代码
	 * @return
	 */
	@Column(name = "port_code")
	private String				port_code;
	/**
	 * 报价公司海关代码
	 * @return
	 */
	@Column(name = "com_customs_code")
	private String				com_customs_code;
	/**
	 * 备注
	 * @return
	 */
	@Column(name = "remark")
	private String				remark;
	/**
	 * 备注
	 * @return
	 */
	@Column(name = "IMP_REMARK")
	private String				impRemark;

	public DeclarationOffer() {}

	public DeclarationOffer(Double declaration_amount, Double imp_declaration_amount,
	        Integer container_amount, Integer imp_container_amount, String remark) {
		this.declaration_amount = declaration_amount;
		this.imp_declaration_amount = imp_declaration_amount;
		this.container_amount = container_amount;
		this.imp_container_amount = imp_container_amount;
		this.remark = remark;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Double getDeclaration_amount() {
		return declaration_amount;
	}

	public void setDeclaration_amount(Double declaration_amount) {
		this.declaration_amount = declaration_amount;
	}

	public Integer getContainer_amount() {
		return container_amount;
	}

	public void setContainer_amount(Integer container_amount) {
		this.container_amount = container_amount;
	}

	public Date getPrice_begin_time() {
		return price_begin_time;
	}

	public void setPrice_begin_time(Date price_begin_time) {
		this.price_begin_time = price_begin_time;
	}

	public Date getPrice_end_time() {
		return price_end_time;
	}

	public void setPrice_end_time(Date price_end_time) {
		this.price_end_time = price_end_time;
	}

	public Date getRegDate() {
		return regDate;
	}

	public void setRegDate(Date regDate) {
		this.regDate = regDate;
	}

	public String getReg_user() {
		return reg_user;
	}

	public void setReg_user(String reg_user) {
		this.reg_user = reg_user;
	}

	public Date getModi_date() {
		return modi_date;
	}

	public void setModi_date(Date modi_date) {
		this.modi_date = modi_date;
	}

	public String getModi_user() {
		return modi_user;
	}

	public void setModi_user(String modi_user) {
		this.modi_user = modi_user;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public Date getReview_date() {
		return review_date;
	}

	public void setReview_date(Date review_date) {
		this.review_date = review_date;
	}

	public String getReview_user() {
		return review_user;
	}

	public void setReview_user(String review_user) {
		this.review_user = review_user;
	}

	public Company getOwner() {
		return owner;
	}

	public void setOwner(Company owner) {
		this.owner = owner;
	}

	public String getConfirm_user() {
		return confirm_user;
	}

	public void setConfirm_user(String confirm_user) {
		this.confirm_user = confirm_user;
	}

	public Attachment getUpload_id() {
		return upload_id;
	}

	public void setUpload_id(Attachment upload_id) {
		this.upload_id = upload_id;
	}

	public String getReview_reason() {
		return review_reason;
	}

	public void setReview_reason(String review_reason) {
		this.review_reason = review_reason;
	}

	public String getDeclaration_company() {
		return declaration_company;
	}

	public void setDeclaration_company(String declaration_company) {
		this.declaration_company = declaration_company;
	}

	public String getDeclaration_company_id() {
		return declaration_company_id;
	}

	public void setDeclaration_company_id(String declaration_company_id) {
		this.declaration_company_id = declaration_company_id;
	}

	public String getPort() {
		return port;
	}

	public void setPort(String port) {
		this.port = port;
	}

	public String getPort_code() {
		return port_code;
	}

	public void setPort_code(String port_code) {
		this.port_code = port_code;
	}

	public String getCom_customs_code() {
		return com_customs_code;
	}

	public void setCom_customs_code(String com_customs_code) {
		this.com_customs_code = com_customs_code;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Double getImp_declaration_amount() {
		return imp_declaration_amount;
	}

	public void setImp_declaration_amount(Double imp_declaration_amount) {
		this.imp_declaration_amount = imp_declaration_amount;
	}

	public Date getConfirmTime() {
		return confirmTime;
	}

	public void setConfirmTime(Date confirmTime) {
		this.confirmTime = confirmTime;
	}

	public Integer getImp_container_amount() {
		return imp_container_amount;
	}

	public void setImp_container_amount(Integer imp_container_amount) {
		this.imp_container_amount = imp_container_amount;
	}

	public String getStateLabel() {
		if(this.state == null) {
			return "";
		}
		String label;
		String[] labelPicker = {"草稿", "提交", "已确认", "驳回", "结束", "报价生效", "待生效", "报价已过期" };
		switch (this.state) {
			case "OS00":
				label = labelPicker[0];
				break;
			case "OS01":
				label = labelPicker[1];
				break;
			case "OS02":
				label = labelPicker[2];
				break;
			case "OS03":
				label = labelPicker[3];
				break;
			case "OS04":
				label = labelPicker[4];
				break;
			case "OS05":
				if(this.price_begin_time.after(new Date())) {
					label = labelPicker[6];
				} else if(this.price_end_time.before(new Date())) {
					label = labelPicker[7];
				} else {
					label = labelPicker[5];
				}
				break;
			default:
				label = "";
		}
		return label;
	}

	public String getImpRemark() {
		return impRemark;
	}

	public void setImpRemark(String impRemark) {
		this.impRemark = impRemark;
	}
}
